Shell if-B Returns True when file exists and is a block file-C Returns True when file exists and is a character-D returns True when pathname exists and is a directory-E Returns True when a file or directory specified by pathname is present-F Returns
Original address: http://blog.chinaunix.net/uid-24607609-id-2118151.htmlThe syntax for the most streamlined if command is:if TEST-COMMANDS; then CONSEQUENT-COMMANDS; fiafter the Test-command executes and its return status is 0, the
/********************************************************************* * Makefile How to use shell if judgment * Description: * For example, it may be necessary to determine the existence of files, folders in Makfile, use shell syntax * To output
Linux Shell if parameterUsed in shell programming to determine parameters within an if statement–b return True when file exists and is a block file-C Returns True when file exists and is a character-D returns True when pathname exists and is a
Primary
Meaning
[- File]
True ifFileExists.
[-B File]
True ifFileExists and is a block-special file.
[-C File]
True ifFileExists and is a character-special file.
[-D File]
True ifFileExists and
[Shell] if common judgment ConditionsIF you have written a simple shell script before the judgment, it is not a job O & M, and the work related to the system is relatively small, so it is not very skilled.Recently, as the system has encountered
[Shell] if common judgment conditions and shellif judgment ConditionsIF judgmentI have also written a simple shell script before, and it is not transferred to O & M. It has less work related to the system, so it is not very skilled.Recently, as the
[ -a file] is true if file exists. [ -b file] True if file exists and is a block special file. [ -c file] True if file exists and is a word special. [ -d file] True if file exists and is a directory. [ -e file] is true if file exists. [ -f file]
if [$#! = 1]; Thenecho "USAGE: $ tabname"echo "e.g.: $ cdr_call_20040701"Exit 1;FiLocation parameters $ #代表了命令行的参数数量, $ $,..., $N, and $ A represents the name of the script-ne Not equal to-----------------------Used in shell programming to determine
If usage:if []; thenCommandelif []; thenCommandElseCommandFiIf parameter:Used in shell programming to determine parameters within an if statement–b return True when file exists and is a block file-C Returns True when file exists and is a character-D
If condition test common syntax
Test
[]
[[]]
())
Test command AND [] testing operator
Test
[]
(these two syntaxes are equivalent)
test operator
full Spell
If statement 1.1 if statement explanation
If is a judgment statement, if the action is similar to [], the general judgment is more or the execution of the statement is more, then will use if
1.2 If format
First format
if [
In linux shell if parameter shell programming, the if statement is used to determine the parameter www.2cto.com-B. When the file exists and is a block file, true-c is returned when the file exists and is a character file. -d. When pathname exists
From http://vc88.javaeye.com/blog/658764
Shell if interpretation statement[Front and back Spaces] Leading space[-A file] true if the file exists.[-B file] If the file exists and is a special block file, it is true.[-C file] If the file exists
Used in shell programming to determine parameters within an if statement–b return True when file exists and is a block file-C Returns True when file exists and is a character-D returns True when pathname exists and is a directory-E Returns True when
No matter what programming language is inseparable from conditional judgment. The shell is no exception.The approximate format is as follows:If List ThenDo something hereElif List ThenDo another thing hereElseDo something else hereFiAn
The conditional judgment statement in the shell is an upgrade to the previous "conditional test statement in the shell", meaning that the preceding test statement serves the IF~THEN~FI statement for the current judgment statement.We're still rolling
The IF statement determines which branch to execute by using relational operators to determine whether an expression is true or false. The Shell has three kinds of if ... else statements:
If ... fi statement;
If ... else ... fi
The IF statement determines which branch to execute by using relational operators to determine whether an expression is true or false. The Shell has three kinds of if ... else statements:
If ... fi statement;
If ... else ... fi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.